package com.github.andy0106.kersstjtl.files;

import java.nio.charset.StandardCharsets;
import java.nio.file.StandardOpenOption;

public interface Writeable {
    boolean write(byte[] bytes, StandardOpenOption... openOption);
    default boolean write(byte[] bytes) {
        return write(bytes, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
    }

    default boolean append(byte[] bytes) {
        return write(bytes, StandardOpenOption.WRITE, StandardOpenOption.APPEND);
    }

    default boolean writeString_UTF_8(String s) {
        return write(s.getBytes(StandardCharsets.UTF_8));
    }

    default boolean appendString_UTF_8(String s) {
        return append(s.getBytes(StandardCharsets.UTF_8));
    }
}
